/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ManagersUI;

import java.io.IOException;
import java.util.logging.*;
import javafx.fxml.FXMLLoader;
import javafx.scene.*;
import ControladoresUI.LoginController;
import ControladoresUI.SelectorPermisoController;
import Entidades.Usuario;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 *
 * @author JEscalante
 */
public class LoginManager {
    private Scene scene;
    private Stage stage;
    public LoginManager(Scene scene, Stage stage) {
        this.scene = scene;
        this.stage = stage;
    }
    public void showVentanaPrincipal(Usuario usuario){
        scene = new Scene(new StackPane());
        VentanaPrincipalManager ventanaPrincipalManager = new VentanaPrincipalManager(scene,stage);
        ventanaPrincipalManager.showVentanaPrincipal(usuario);
        stage.setScene(scene);
        stage.show();
        
      /*  Stage nuevaStage = new Stage();
        nuevaStage.setTitle("My New Stage Title");
        nuevaStage.setScene(scene);
        nuevaStage.show(); */
    }
    public void showPnlUsuarios(Usuario usuario){
        scene = new Scene(new StackPane());
        UsuariosManager usuariosManager = new UsuariosManager(scene,stage);
        usuariosManager.abrirPanelUsuarios(usuario);
        stage.setScene(scene);
        stage.show();
     }
    /**
     * Callback method invoked to notify that a user has logged out of the main application.
     * Will show the login application screen.
     */ 
    public void logout() {
      showLoginScreen();
    }

    public void showLoginScreen() {
      try {
        FXMLLoader loader = new FXMLLoader(
          getClass().getResource("/VistasUI/frmLogin.fxml")
        );
        scene.setRoot((Parent) loader.load());
        LoginController controller = 
          loader.<LoginController>getController();
        controller.initManager(this);
      } catch (IOException ex) {
        Logger.getLogger(LoginManager.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
}
